const mime = require('mime');

let txt = 'xxx.txt';

let a = mime.getType(txt); // 通过名字取得mime类型
console.log(a);

let b = mime.getExtension(a);  // 通过mime取得后缀
console.log(b);
